<template>
  <div @click="$router.push('/article/' + item.art_id)">
    <div class="article-item van-hairline--bottom" v-if="item.cover.type === 0">
      <p class="title van-multi-ellipsis--l2">
        {{ item.title }}
      </p>
      <div class="info">
        <span>{{ item.aut_name }}</span>
        <span>{{ item.comm_count }}</span>
        <span>{{ item.pubdate | filtersTimeGlobal }}</span>
        <geek-icon name="esay-close"></geek-icon>
      </div>
    </div>
    <div
      class="article-item van-hairline--bottom"
      v-else-if="item.cover.type === 3"
    >
      <p class="title van-multi-ellipsis--l2">
        {{ item.title }}
      </p>
      <img
        class="img"
        :src="i"
        alt=""
        v-for="(i, index) in item.cover.images"
        :key="index"
      />

      <div class="info">
        <span>{{ item.aut_name }}</span>
        <span>{{ item.comm_count }}</span>
        <span>{{ item.pubdate | filtersTimeGlobal }}</span>
        <geek-icon name="esay-close"></geek-icon>
      </div>
    </div>
    <div class="article-item van-hairline--bottom" v-else>
      <p class="title van-multi-ellipsis--l2 w66">
        {{ item.title }}
      </p>
      <img class="img" :src="item.cover.images[0]" alt="" />
      <div class="info">
        <span>{{ item.aut_name }}</span>
        <span>{{ item.comm_count }}</span>
        <span>{{ item.pubdate | filtersTimeGlobal }}</span>
        <geek-icon name="esay-close"></geek-icon>
      </div>
    </div>
  </div>
</template>

<script>
// 局部过滤器
// // 导入dayjs
// import dayjs from 'dayjs'
// // 导入相对时间依赖
// import relativeTime from 'dayjs/plugin/relativeTime'
// //导入语音包
// import 'dayjs/locale/zh-cn'
// // 使用中文
// dayjs.locale('zh-cn')
// // 使用依赖插件
// dayjs.extend(relativeTime)
export default {
  props: ['item'],
  name: 'ArticleItem'
  // 注册过滤器
  // filters: {
  //   formatTime (tiem) {
  //     return dayjs(tiem).toNow()
  //   }
  // }
}
</script>
<style scoped lang="less">
.article-item {
  padding: 15px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  .title {
    width: 100%;
    margin: 0;
    line-height: 22px;
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
    max-height: 44px;
    &.w66 {
      width: 66%;
    }
  }
  .img {
    width: 112px;
    height: 74px;
    border-radius: 4px;
    margin-bottom: 8px;
  }
  .info {
    width: 100%;
    color: #a5a6ab;
    font-size: 12px;
    position: relative;
    span {
      margin-right: 12px;
    }
    .geek-icon {
      float: right;
      font-size: 14px;
    }
  }
}
</style>
